'use strict';
const checkParams = require('check_params');
exports.main = async (params, context) => {
	//event为客户端上传的参数
	const db = uniCloud.database();
	let res= {}, regParams = checkParams(params,{id:"文章id不能为空, check "});
	if(params.id){
		console.log('params id',regParams);
		let result =await db.collection("opendb-news-articles")
			.field({title:!0,content:!0,view_count:!0,like_count:!0})
			.where({
				_id: params.id,
			}).get();
			console.log('sql',result.data);
			res = {
				code:1,
				data:result.data[0],
				msg:'操作成功'
			}
	}else{
		res = {
			code: 1,
			data:null,
			msg:"文章id 不能为空"
		}
	}
	
	//返回数据给客户端
	return res
};
